package com.sfh.story;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import cn.bmob.v3.BmobObject;
import cn.bmob.v3.listener.SaveListener;

import com.sfh.story.entrty.Story;
import com.sfh.story.entrty.StoryContent;
import com.sfh.story.entrty.StoryDetil;
import com.sfh.story.entrty.StoryType;

public class Mananger
{
    public static void addType(Context context, SaveListener listener)
    {
        List<BmobObject> objects = new ArrayList<BmobObject>();
        
        StoryType storyType = new StoryType();
        storyType.setName("睡前故事");
        storyType.setSize(0);
        storyType.setType(1);
        storyType.setIcon("http://img3.imgtn.bdimg.com/it/u=2428877782,3430948389&fm=21&gp=0.jpg");
        objects.add(storyType);
        
        StoryType storyType1 = new StoryType();
        storyType1.setName("安徒生");
        storyType1.setSize(0);
        storyType1.setType(2);
        storyType1.setIcon("http://img4.imgtn.bdimg.com/it/u=4245445682,3158930&fm=23&gp=0.jpg");
        objects.add(storyType1);
        
        StoryType storyType2 = new StoryType();
        storyType2.setName("一千零一夜");
        storyType2.setSize(0);
        storyType2.setType(3);
        storyType2.setIcon("http://img2.imgtn.bdimg.com/it/u=3615338647,1119761537&fm=23&gp=0.jpg");
        objects.add(storyType2);
        
        StoryType storyType3 = new StoryType();
        storyType3.setName("格林童话");
        storyType3.setSize(0);
        storyType3.setType(4);
        storyType3.setIcon("http://img2.imgtn.bdimg.com/it/u=1278147917,4124183167&fm=23&gp=0.jpg");
        objects.add(storyType3);
        
        StoryType storyType4 = new StoryType();
        storyType4.setName("成语故事");
        storyType4.setSize(0);
        storyType4.setType(5);
        storyType4.setIcon("http://img1.imgtn.bdimg.com/it/u=2185605472,3748965121&fm=23&gp=0.jpg");
        objects.add(storyType4);
        
        new BmobObject().insertBatch(context, objects, listener);
    }
    
    public static void addStoryContent(Context context, SaveListener listener, Story story, String storyID)
    {
        List<BmobObject> objects = new ArrayList<BmobObject>();
        for (int i = 0; i < story.content.size(); i++)
        {
            objects.add(new StoryContent(story.content.get(i), storyID, i));
        }
        new BmobObject().insertBatch(context, objects, listener);
        
    }
}
